import request from '@/utils/request'

// 分页查询预约信息
export function getAppointmentPage(params) {
    return request({
        url: '/appointment/page',
        method: 'get',
        params
    })
}

// 获取用户的预约列表
export function getUserAppointments(userId) {
    return request({
        url: `/appointment/user/${userId}`,
        method: 'get'
    })
}

// 新增预约
export function addAppointment(data) {
    return request({
        url: '/appointment/add',
        method: 'post',
        data
    })
}

// 更新预约信息
export function updateAppointment(data) {
    return request({
        url: '/appointment/update',
        method: 'post',
        data
    })
}

// 取消预约
export function cancelAppointment(id) {
    return request({
        url: `/appointment/cancel/${id}`,
        method: 'post'
    })
}

// 审核预约
export function reviewAppointment(id, status, remark) {
    return request({
        url: `/appointment/review/${id}`,
        method: 'post',
        params: {status, remark}
    })
}

// 获取时间段预约统计数据
export function getTimeSlotStatistics(date) {
    return request({
        url: '/appointment/statistics/timeSlot',
        method: 'get',
        params: { date }
    })
}